package china.lzy.controller;

import china.lzy.api.ShopControllerApi;
import china.lzy.entity.ResResult;
import china.lzy.entity.dto.PageDto;
import china.lzy.entity.pojo.Shop;
import china.lzy.service.ShopService;
import china.lzy.utils.anno.Authorization;
import china.lzy.utils.anno.NoAuthorization;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @author ：lzy
 * @ Date       ：Created in 10:37 2021/8/14
 * @ Description：
 */
@RestController
@RequestMapping(value = "/shop")
public class ShopController implements ShopControllerApi {

    @Resource
    private ShopService shopService;

    /**
     * 新增
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @NoAuthorization
    @PostMapping("/insert")
    @Override
    public ResResult insert(@RequestBody Shop shop) {
        return shopService.insert(shop);
    }

    /**
     * 刪除
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @Authorization({"admin"})
    @PostMapping("/delete/{id}")
    public ResResult delete(@PathVariable int id) {
        return shopService.delete(id);
    }

    /**
     * 更新
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @Authorization({"admin"})
    @PostMapping("/update")
    public ResResult update(@RequestBody Shop shop) {
        return shopService.update(shop);
    }

    /**
     * 查询 根据主键 id 查询
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @Authorization({"admin"})
    @PostMapping("/load/{id}")
    public ResResult load(@PathVariable int id) {
        return shopService.load(id);
    }

    /**
     * 查询 分页查询
     *
     * @author lzy
     * @date 2021/08/16
     **/
    @Authorization({"admin"})
    @PostMapping("/pageList")
    public ResResult pageList(@RequestBody PageDto page) {
        return shopService.pageList(page);
    }

}
